/*
 * IJKSDLAudioUnitController.h
 *
 * Copyright (c) 2013 Bilibili
 * Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
 *
 * based on https://github.com/kolyvan/kxmovie
 *
 * This file is part of ijkPlayer.
 *
 * ijkPlayer is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * ijkPlayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with ijkPlayer; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#import <Foundation/Foundation.h>
#import <ShazamKit/ShazamKit.h>

#include "ijksdl/ijksdl_aout.h"
#include "lame.h"

#import <libavformat/avformat.h>
#import <libavcodec/avcodec.h>

typedef void(^RecognizeMusicBlock)(const char *songName,const char *artistName,const char *avator,const char *id1,const char *id2) ;
typedef void(^BlockType)(const char *type,void *data) ;

@interface IJKSDLAudioUnitController : NSObject<SHSessionDelegate>

// 识别歌曲的回调
@property (nonatomic,copy) RecognizeMusicBlock recognizeMusic;
// 任意回调
@property (nonatomic,copy) BlockType blockType;

@property (nonatomic,assign) AVFormatContext *formatContext;
@property (nonatomic,assign) AVCodecContext *codecContext;
@property (nonatomic,assign) lame_t lame;
@property (nonatomic,assign) FILE *mp3_file;

@property (nonatomic,strong) SHSession *session;         // 听歌识曲
@property (nonatomic,assign) BOOL isRecording;          // 标识是否正在录制
@property (nonatomic,assign) CGFloat recordTime;        // 录制的总时长 秒

@property (nonatomic, readonly) SDL_AudioSpec spec;

- (id)initWithAudioSpec:(const SDL_AudioSpec *)aSpec recognizeMusic:(RecognizeMusicBlock)recognizeMusic blockType:(BlockType)blockType;

- (void)play;
- (void)pause;
- (void)flush;
- (void)stop;
- (void)close;

- (AVAudioPCMBuffer *)loadPCMBufferFromData:(NSData *)pcmData;

// yc add click line 9
- (void)startRecord:(char *)path;
- (void)stopRecord;
- (void)setEQ:(NSInteger)index;
- (void)setRecognize:(NSInteger)index;

@end

